<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
	<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
	<title>AsynTree Test</title>
	<link rel="stylesheet" type="text/css" media="all" href="css/tinytree.css"  />
	<script type="text/javascript" src="jquery-1.2.6.js"></script>
	<script type="text/javascript" src="jquery.tinytree.js"></script>
	<script type="text/javascript">
		$(function() {
			var addedNodeId = 11;
			
			var nodes = [
			         		{id : '1',
			         		 name : 'node1',
			         		 leaf : false,
			         		 children : [
			         		 	{id : '11',
				         		 name : 'node11',
				         		 leaf : true
				         		},
				         		{id : '12',
					         	 name : 'node12',
					         	 leaf : true
					         	}
			         		 ]
			         		},
			         		{id : '2',
			         		 name : 'node2',
			         		 leaf : true
			         		}	
			         	];
			$('#container').addStaticNodes({
				url : false,
				dataType : 'json',
				//radioSupport : true
				checkboxSupport : true,
				selectLeafOnly : false,
				alsoCheckChildren : false,
				alsoCheckParent : false,
				openAllNodes : true,
				//nodeUrl : 'http://192.168.2.73:8080/asyntree/servlet/ResponseServlet'
				nodeUrl : false
			}, nodes);

			$('#getSelectedNodes').click(function(e) {
				window.alert(parseReturnMessage($('#container')[0].tinytree.getSelecetedNodes()));
			});

			$('#addNodes').click(function(e) {
				var nodes = [
					         {id : 1 + (addedNodeId * 10),
					          name : 'node' + (1 + (addedNodeId * 10)),
					          leaf : false,
					          children : [
					         	{id : 11 + (addedNodeId * 10),
						         name : 'node' + (11 + (addedNodeId * 10)),
						         leaf : true
						        },
						        {id : 12 + (addedNodeId * 10),
							     name : 'node' + (12 + (addedNodeId * 10)),
							     leaf : true
							    }
					          ]
					         },
					         {id : (2 + (addedNodeId * 10)),
					          name : 'node' + (2 + (addedNodeId * 10)),
					          leaf : true
					         }	
					       ];
				$('#container').addNodesTo(addedNodeId, nodes);
			    addedNodeId = 1 + (addedNodeId * 10);
			});
		});	
		function parseReturnMessage(results) {
			var log = '[\n';
			$.each(results, function(i, result) {
				log += '{nodeId=' + result.nodeId + ', nodeName=' + result.nodeName + '}\n';
			});
			log += ']\n';
			return log;
		}
	</script>
	
</head>
<body>
	<div id="container"></div>
	
	<input type="button" id="getSelectedNodes" value="getSelectedNodes" /> 
	
	<br />
	
	<input type="hidden" id="addNodes" value="addNodes" />
</body>
</html>